import { request } from "@/utils/service"
import { Orginfo } from "./types/org"
import { OrgQuery } from "./types/orgQuery"
import { PageData } from "types/pageData"
/**
 * 懒加载获取机构树
 * @param query
 * @returns
 */
export async function getLazyOrgList(query: OrgQuery): Promise<ApiResponseData<PageData<Orginfo>>> {
  return request<ApiResponseData<PageData<Orginfo>>>({
    url: "api/orginfo/GetLazyOrgList",
    method: "get",
    params: query
  })
}
/**
 * 获取完整的机构树
 * @returns
 */
export async function getOrgTree(): Promise<ApiResponseData<Orginfo[]>> {
  return request<ApiResponseData<Orginfo[]>>({
    url: "/api/orginfo/GetOrgTree",
    method: "get"
  })
}
/**
 * 创建机构
 * @param data
 * @returns
 */
export async function create(data: Orginfo): Promise<ApiResponseData<boolean>> {
  return request<ApiResponseData<boolean>>({
    url: "/api/orginfo/Create",
    method: "post",
    data: data
  })
}
/**
 * 更新机构
 * @param data
 * @returns
 */
export async function update(data: Orginfo): Promise<ApiResponseData<boolean>> {
  return request<ApiResponseData<boolean>>({
    url: "/api/orginfo/Update",
    method: "post",
    data: data
  })
}
/**
 * 删除机构
 * @param params
 * @returns
 */
export async function del(params: any): Promise<ApiResponseData<boolean>> {
  return request<ApiResponseData<boolean>>({
    url: "/api/orginfo/Delete",
    method: "get",
    params: params
  })
}
